package com.lsp.server.product.controller;

import com.lsp.server.common.Apiresponse;
import com.lsp.server.product.service.AttrService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName AttrController
 * @Description 商品属性控制层
 * @Author Mr Hao
 * @Date 2021/11/23 15:15
 */
@RestController
@RequestMapping("/attr")
public class AttrController {
    @Autowired
    private AttrService attrService;

    /**
     * 分页获取商品属性列表
     * @return
     */
    @PostMapping("list")
    public Apiresponse getList(Integer page,Integer size,String name,Integer isSku,Integer id){
        try {
            if (null == page || null == size){
                return Apiresponse.Error(400,"参数错误");
            }
            Map map = new HashMap();
            map.put("page",page);
            map.put("size",size);
            map.put("name",name);
            map.put("id",id);
            map.put("isShu",isSku);
            return Apiresponse.success(attrService.getList(map));
        }catch (Exception e){
            return Apiresponse.Error(500,e.getMessage());
        }
    }
}
